package com.woniuxy01;

/**
 * @author 作者
 * @create 2025-11-05 9:33
 */
public class Test01 {
    public static void main(String[] args) {
        //大串中查找子串，子串查找
        String source="xyzajavabcjavadejavfgjavaxxxjava";
        String targe="java";
        int count = getCount(source, targe);
        System.out.println(count);

    }

    private static int getCount(String source, String targe) {
        int index=-1,count=0;
        while(true){
            index = source.indexOf(targe);
            if(index==-1){
                break;
            }
            count++;
            source = source.substring(index+ targe.length());
        }
        return count;
    }


    //返回值，数组第一个元素代表xxx,第二个
    public static int[] count(String str){
        int num=0,small=0,big=0;
        char[] chars = str.toCharArray();
        for(char mychar : chars){
            if(mychar>='a' && mychar<='z'){
                small++;
            }else if(mychar>='A' && mychar<='Z'){
                big++;
            }else if(mychar>='0' && mychar<='9'){
                num++;
            }
        }
        return new int[]{num,small,big};
    }

    //String反转
    private static String stringReverse(String str) {
        char[] chars = str.toCharArray();
        for(int i=0,j=chars.length-1;i<j;i++,j--){
            char t=chars[i];
            chars[i]=chars[j];
            chars[j]=t;
        }
        str =new String(chars);
        return str;
    }


}
